Skip to content

fix(rootfs/qemu-static): use direct armhf exec probe instead of broken arch-test gate#140

Open
iav wants to merge 3 commits into
mainfrom
fix/native-armhf-detection
Open

fix(rootfs/qemu-static): use direct armhf exec probe instead of broken arch-test gate#140
iav wants to merge 3 commits into
mainfrom
fix/native-armhf-detection

Conversation

@iav
Copy link
Copy Markdown
Owner

@iav iav commented May 22, 2026

codex-trap mirror of upstream PR armbian#9820 (re-opened after force-push made the old head commit unreachable; previous trap was #117).

Latest CR nitpick fix (|| true outside run_host_command_logged arch-test in SHOW_DEBUG=yes debug branch) is included; squashed into the single commit.

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d6d4728c3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/functions/rootfs/qemu-static.sh Outdated
Comment thread lib/functions/rootfs/qemu-static.sh
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 42eb08da2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/functions/rootfs/qemu-static.sh Outdated
…n arch-test gate

`arch-test arm` probes ARMv5 EABI, divergent from kernel COMPAT (armhf
EABI v5+), and returns failure on modern aarch64 hosts (Ubuntu Noble
6.8 / Ampere Altra) with a fully working CONFIG_COMPAT path — routing
mmdebstrap through qemu-user emulation at ~10× slowdown. Replace with
a 4-tier detection: prefer the packaged `/usr/share/binfmts/qemu-arm`
descriptor if present, trust an already-enabled kernel registration,
otherwise probe COMPAT directly by exec'ing `ld-linux-armhf.so.3`,
falling back to the hand-rolled descriptor only when none applies.

Assisted-by: Claude:claude-opus-4.7
@iav iav force-pushed the fix/native-armhf-detection branch 2 times, most recently from c456ae4 to 1c66025 Compare May 25, 2026 01:35
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c66025814

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/functions/rootfs/qemu-static.sh Outdated
@iav iav force-pushed the fix/native-armhf-detection branch from 1c66025 to 12f0371 Compare May 25, 2026 02:12
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

iav added 2 commits May 26, 2026 07:08
…registration

When CONFIG_COMPAT runs armhf binaries natively on aarch64 (≈10× faster
than qemu-user emulation), but qemu-arm is registered in kernel binfmt_misc,
the previous "trust existing setup" check returned early and the build
went through qemu anyway. Empirically: helios4 build 41 min via qemu vs
19 min native COMPAT on droid (RK3399).

Reorder probes:

1. Snapshot initial qemu-arm state.
2. COMPAT probe must run with qemu-arm OFF — kernel binfmt_misc routes
   armhf exec through qemu first when enabled, making the probe a liar
   about native capability. Temp-disable before probe; on probe failure
   (no COMPAT, e.g. Apple Silicon under HVF where AArch32@EL0 SIGILL's)
   restore qemu-arm and fall through to qemu setup. Toggle errors are
   not swallowed.
3. Trust-existing path validates via arch-test arm — the `enabled` flag
   alone does not attest that the interpreter actually runs (stale path,
   removed package); without this, broken registrations passed setup
   and failed later in chroot.
4. _verify_qemu_arm_executes helper called after each successful
   import/enable/repair branch, so qemu issues fail fast at host-prepare
   time instead of mid-rootfs-build.

The descriptor itself is left intact — only the active flag is toggled.

Gated by ARMBIAN_PREFER_NATIVE_ARMHF=no for explicit opt-out. Behaviour
preserved on hosts without COMPAT.

Assisted-by: Claude:claude-opus-4.7
…uilds

Spell out the practical effect of CONFIG_COMPAT + COMPAT_VDSO + ARM64_32BIT_EL0:
an arm64 host running such a kernel can execute armhf userspace natively, so
rootfs/chroot steps run native instead of via qemu-user-static (~10× faster).
Cross-reference the rootfs probe and the ARMBIAN_PREFER_NATIVE_ARMHF switch,
and note the Apple-M-series exception (no AArch32@EL0 in silicon).

Assisted-by: Claude:claude-opus-4.7
@iav iav force-pushed the fix/native-armhf-detection branch from 752bb11 to dbd7005 Compare May 26, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant